package com.jeecg.study.listeners;

import java.util.Map;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import javax.swing.plaf.basic.BasicSliderUI.ActionScroller;

import com.jeecg.study.common.utils.PropertiesUtils;
import com.jeecg.study.common.utils.XmlUtilsNew;
import com.jeecg.study.entity.XmlBeans;
import com.jeecg.study.servlets.ServletAction;

/**
 * Application Lifecycle Listener implementation class ActionListeners
 *
 */
@WebListener
public class ActionListeners implements ServletContextListener {

    /**
     * Default constructor. 
     */
    public ActionListeners() {
        // TODO Auto-generated constructor stub
    }

	/**
     * @see ServletContextListener#contextDestroyed(ServletContextEvent)
     */
    public void contextDestroyed(ServletContextEvent arg0)  { 
         // TODO Auto-generated method stub
    }

	/**
     * @see ServletContextListener#contextInitialized(ServletContextEvent)
     */
    public void contextInitialized(ServletContextEvent arg0)  { 
    	String xmlPath = arg0.getServletContext().getRealPath("\\")+arg0.getServletContext().getInitParameter("configLoaction");
    	Map<String, XmlBeans> xmlMap = XmlUtilsNew.readXMlFile(xmlPath);
    	ServletAction.mapNew=xmlMap;
    	arg0.getServletContext().setAttribute("xmlMap", xmlMap);
    	String configPath = arg0.getServletContext().getRealPath("\\")+arg0.getServletContext().getInitParameter("jeecgMVC_Config_Path");
    	PropertiesUtils.loadFile(configPath);
    	System.out.println(ActionListeners.class.getName() +" initing ... ");
    }
	
    
}
